import java.io.*;

public class MP3File implements Serializable{

    public byte[] binaryMP3; 
    public boolean creationSuccess; 

    public MP3File(File selectedFile) {
	FileInputStream fis = null;
	try {
	    fis = new FileInputStream(selectedFile);
	}
	catch(FileNotFoundException E){System.out.println("guava");}
	ByteArrayOutputStream buffer = new ByteArrayOutputStream();

	int nRead;
	byte[] data = new byte[262144]; //an arbitrary value for the buffer size: .25 MB. It is large, but most MP3s are 5-10 MB, so it is probably reasonable.
	try {
	    while ((nRead = fis.read(data, 0, data.length)) != -1) {
		buffer.write(data, 0, nRead);
	    }
	    buffer.flush();
	}
	catch(IOException E){System.out.println("kiwi");}
	binaryMP3 = buffer.toByteArray();
    }
    public InputStream getStream() {
	ByteArrayInputStream stream = new ByteArrayInputStream(binaryMP3);
	return (InputStream)stream;
    }

}